// src/requests/auth.js
import RequestManager from "@utils/request";

//判断用户名是否被使用
export function usernamesRequest(username){
    return RequestManager.instance.request({
        url : `usernames/${username}/count/`,
        method : 'GET'
    })
}
// 判断手机号是否被注册
export function PhoneNumberRequest(mobile){
    return RequestManager.instance.request({
        url:`mobiles/${mobile}/count/`,
        method:'GET'
    })
}
// 用户注册
export function registerRequest(user) {
    return RequestManager.instance.request({
        url: "register/",
        method: "POST",
        data: { ...user },
    });
}

// 用户登录
export function SignInRequest(user){
    return RequestManager.instance.request({
        url : "user/login/",
        method : "POST",
        data:{...user}
    })
}

// 退出登录
export function LogoutRequest(){
    return RequestManager.instance.request({
        url : "user/logout/",
        method:'DELETE'
    })
}

// 用户中心数据茶询
export function UserCenterRequest(username){
    return RequestManager.instance.request({
        url:`user/info/${username}/`,
        method : 'GET'
    })
}

// 用户中心数据修改
export function UserModifRequest(user){
    // console.log(user)
    return RequestManager.instance.request({
        url : 'user/modify/',
        method : 'POST',
        data : {...user}
    })
}
// 用户头像修改
export function  UserImgRequest(userImg){
    return RequestManager.instance.request({
        url:'user/img/',
        method : 'POST',
        data:userImg
    })
}

